//-----------------------------------------------------------------------
// <copyright file="TimeLog.cs" company="Simnova LLC">
//     Copyright (c) Simnova LLC. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------

namespace Simnova.Collaborate.ServiceContract.DataClasses
{
    using System;
    using System.Runtime.Serialization;

    [DataContract]
    public class TimeLog
    {
        [DataMember(Name = "TimeLogId")]
        private int timeLogId;
        private int userId;
        private int? activityTypeId;
        private int? taskId;
        private string description;
        [DataMember(Name = "Duration")]
        private int duration;
        [DataMember(Name = "CreateDate")]
        private DateTime createDate = DateTime.Now;
        [DataMember(Name = "StartTime")]
        private DateTime startTime = DateTime.Now;
        private DateTime? endTime;
        private int remainingHours;

        public int TimeLogId
        {
            get { return this.timeLogId; }
        }

        [DataMember]
        public int ActivityTypeId
        {
            get 
            { 
               if (this.activityTypeId.HasValue)
               {
                   return this.activityTypeId.Value;
               } 
               else
               {
                   return 0;
               }
            }

            set
            {
                if (value == 0)
                {
                    this.activityTypeId = null;
                }
                else
                {
                    this.activityTypeId = value;
                }
            }
        }

        [DataMember]
        public int TaskId
        {
            get
            {
                if (this.taskId.HasValue)
                {
                    return this.taskId.Value;
                }
                else
                {
                    return 0;
                }
            }

            set
            {
                if (value == 0)
                {
                    this.taskId = null;
                }
                else
                {
                    this.taskId = value;
                }
            }
        }

        [DataMember]
        public int UserId
        {
            get { return this.userId; }
            set { this.userId = value; }
        }

        [DataMember]
        public string Description
        {
            get { return this.description; }
            set { this.description = value; }
        }
      
        public int Duration
        {
            get { return this.duration; }
            set { this.duration = value; }
        }

        public DateTime CreateDate
        {
            get { return this.createDate; }
        }

        public DateTime StartTime
        {
            get { return this.startTime; }
        }

        public DateTime EndTime
        {
            get 
            {
                if (this.endTime.HasValue)
                {
                    return this.endTime.Value;
                }
                else
                {
                    return this.startTime;
                }
            }

            set 
            { 
                this.endTime = value; 
            }
        }

        [DataMember]
        public int RemainingHours
        {
            get { return this.remainingHours; }
            set { this.remainingHours = value; }
        }
    }
}
